//
//  AIFAccountRegisterManager.m
//  PywSdk
//
//  Created by Jade on 4/12/16.
//  Copyright © 2016 zero. All rights reserved.
//

#import "AIFAccountRegisterManager.h"

@implementation AIFAccountRegisterManager

NSString *const Register_PASSPORT = @"passport";
NSString *const Register_GAMEID = @"gameid";
NSString *const Register_SIGN = @"sign";
NSString *const Register_TID = @"tid";
NSString *const Register_Passport_token = @"passport_token";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
/**
 *  方法名称
 *
 *  @return methodName
 */
- (NSString *)methodName
{
    return URL_ACCOUNT_REGISTER;
}
- (NSString *)seriviceType
{
    return [PywAppInfo sharedAppInfo].seriviceType;
}

/**
 *  请求类型
 *
 *  @return request type
 */
- (ETAPIManagerRequestType)requestType
{
    return ETAPIManagerRequestTypePost;
}



#pragma mark - ETAPIManagerParamSourceDelegate

- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager
{
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    //流水号
    NSString *tid = [[PywAppInfo sharedAppInfo] tid];
    NSString * _gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString * apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    NSString *passport = [PywPlatformMain sharedPlatformMain].passport;
    NSString *passportToken = [PywPlatformMain sharedPlatformMain].passport_Token;
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",_gameid,passport,apiSecret2];
    sign = [PywCipherUtils md5:sign];
    
    NSString *rsaPassPort = [passport debugDescription];
    [param setObject:rsaPassPort forKey:Register_PASSPORT];
    [param setObject:_gameid forKey:Register_GAMEID];
    [param setObject:sign forKey:Register_SIGN];
    [param setObject:tid forKey:Register_TID];
    [param setObject:passportToken forKey:Register_Passport_token];
    return param;
}



#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}

@end
